<?php

namespace App\Services\Base;
use App\Models\Base\ApiLog;
use App\Params\Backend\SettingUpdateParam;
use App\Repository\SystemConfigRepository;
use App\Services\BaseService;

/**
 * 参数配置相关业务类
 *
 * @author WangBin
 * @date 2022-01-11
 * @package App\Http\Services
 */
class SettingService extends BaseService
{
    /**
     * 保存配置数据
     *
     * @param SettingUpdateParam $param
     * @return int|mixed
     */
    public function update(SettingUpdateParam $param)
    {
        return SystemConfigRepository::getInstance()->save($param->toArray());
    }

    /**
     * 获取所有的配置信息
     *
     * @return array
     */
    public function get()
    {
        $result = SystemConfigRepository::getInstance()->getList('h5')->get();
        $plucked = $result->pluck('value', 'config_key');
        return $plucked->all();
    }
}
